<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>分配角色</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form" style="width:80%;" lay-filter="dataFrm" id="dataFrm" >
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">分配人员:</label>
        <div class="layui-input-block">
            <select id="assignPeoplezz" name="assignee" class="basicTypeGrade" lay-filter="assignPeoplezz">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">分配时间:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input distributeTime" lay-verify="required" name="distributeTime" placeholder="请确定当前时间" id="distributeTimezz">
        </div>
    </div>
    <!--给用户分配角色的弹出层-->
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <input type="hidden" id="serviceIdHiden"></input>
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addService">分配</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script th:inline="none">
    var html = "";
    layui.use(['form','layer','table','laytpl','laydate','upload'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate=layui.laydate,
            upload = layui.upload;
        //动态绑定下拉菜单的数据
        $.ajax({
            url:'custs.do',
            success:function (data) {
                html += "<option value=''>------------请选择------------</option>"
                for (i = 0; i < data.length; i++) {
                    html += ("<option value='" + data[i].cust_manager_name + "'>" + data[i].cust_manager_name + "</option>")
                }
                $("#assignPeoplezz").html(html);
                form.render('select');
            }
        });
        layui.use('laydate', function() {
            var startTime;
            var laydate = layui.laydate;
            var now=new Date();
            laydate.render({
                elem: '#distributeTimezz',
                theme: 'molv',
                format:'yyyy-MM-dd HH:mm:ss',
                type: 'datetime',
                trigger: 'click',
                ready: function(date){
                    //console.log(date); //得到初始的日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                    this.dateTime.hours=now.getHours()
                    this.dateTime.minutes=now.getMinutes();
                    this.dateTime.seconds=now.getSeconds();
                }

            });
        });
        //分配人员
        form.on("submit(addService)", function (data) {
            var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.4});
            var id=$('#serviceIdHiden').val();
            var ss=$('#assignPeoplezz').val();
            var time=$('#distributeTimezz').val();
            $.post("/service/updatAssagn.do", {id:id, assignee:ss, distributeTime:time}, function (res) {
                console.log(res)
                if (res.code == 200) {
                    setTimeout(function () {
                        top.layer.close(index);
                        top.layer.msg("分配成功！");
                        //刷新父页面
                        parent.location.reload();
                    }, 2000)
                }
            }, "json");
            return false;
        });

    })
    // $("#assignRoleBtn").click(function () {
    //     //获取选中的角色id的集合
    //     var checkStatus = table.checkStatus('roleTable');
    //     var rids=new Array();
    //     $.each(checkStatus.data,function (index,item) {
    //         rids.push(item.id);
    //     });
    //     $.get("/user/assignRole.do",{rids:rids,uid:uuid},function (res) {
    //         console.log(res)
    //         if(res.code==200){
    //             layer.msg(res.msg);
    //             var index1=parent.layer.getFrameIndex(window.name);
    //             parent.layer.close(index1);
    //         }
    //     });
    // });
    // })
</script>

</body>
</html></html>